package com.itggm.controller;

import com.itggm.DTO.MemberPageDTO;
import com.itggm.pojo.Member;
import com.itggm.response.ResponseResult;
import com.itggm.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author: ggm
 * @data 2024年11月18日 11:49
 */
@RestController
@RequestMapping("member")
public class MemberController {

    @Autowired
    private MemberService memberService;

    /**
     * @Author: ggm
     * @date: 2024/11/18
     * 分页查询
     */
    @GetMapping("/page")
    public ResponseResult page(MemberPageDTO memberPageDTO) {
        return memberService.page(memberPageDTO);

    }

    /**
     * @Author: ggm
     * @date: 2024/11/18
     * 添加会员
     */
    @PostMapping("/add")
    public ResponseResult add( Member member) {
        return memberService.add(member);
    }

    // 普通用户注册会员
    @PostMapping("front/register")
    public ResponseResult registerMember(Member member) {

        return memberService.registerMember(member);
    }


    // 会员登录
    @PostMapping("front/login")
    public ResponseResult login(Member member, HttpSession session) {

        return memberService.login(member,session);
    }


    // edit  编辑会员信息
    @PostMapping("edit")
    public ResponseResult editMember(Member member) {

        return memberService.editMember(member);
    }

    // 删除  delete
    @PostMapping("delete")
    public ResponseResult deleteMember(@RequestBody List<Integer> ids) {

        return memberService.deleteMember(ids);
    }


}
